package com.qc31.monitorlib.ui.adapter

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.qc31.comlib.entity.HistoryAlarm
import com.qc31.monitorlib.R

/** @Author Jasper @Time 2020/10/21 @Desc 历史报警 */
class AlarmHistoryAdapter(private val isCar: Boolean = false) :
    BaseQuickAdapter<HistoryAlarm.TotalAlarms, BaseViewHolder>(R.layout.item_history_alarm) {
    override fun convert(holder: BaseViewHolder, item: HistoryAlarm.TotalAlarms) {
        item.run {
            val num = if (isCar) holder.layoutPosition + 1 else holder.layoutPosition
            holder.setText(R.id.tv_alarm_order, num.toString())
                .setText(R.id.tv_alarm_type, name)
                .setText(R.id.tv_alarm_num, total.toString())
            holder.getView<TextView>(R.id.tv_alarm_num)
                .setTextColor(ContextCompat.getColor(context, R.color.color_379))
        }
    }


}